module majiang.Views {
    /**
     * Balance
     */
    export class Balance extends eui.Component{
        //eui
        public startBtn:Mix.Views.Base.Button;
        public restartBtn:Mix.Views.Base.Button;

        //data
        private _states:string = "start";
        private allFanshu:number;
        private allHupaishu:number;

        constructor() {
            super();

            this.once(eui.UIEvent.CREATION_COMPLETE,this.skinCreationComplete,this);
            this.skinName = "balanceSkin";
        }

        protected getCurrentState(){
            return this._states;
        }

        /**
         * gameStart
         */
        public toStartMain() {
            this._states = "start";
            this.invalidateState();
        }

        /**
         * gameOver
         */
        public toOverMain() {
            this.allFanshu = majiang.Datas.Playing.allFan;
            this.allHupaishu = majiang.Datas.Playing.allHu;

            this._states = "over";
            this.invalidateState();
        }

        private skinCreationComplete(){
            this.startBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTapStartBtn,this);
            this.restartBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTapRestartBtn,this);
        }

        private onTapStartBtn(){
            majiang.Controllers.Play.gameStart();
        }

        private onTapRestartBtn(){
            this.toStartMain();
        }
    }
}